package com.scuec.tourismwebsite.mapper;

import com.scuec.tourismwebsite.entity.Admin;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AdminMapper {

    // 查找所有管理员
    @Select("SELECT * FROM Admin")
    List<Admin> findAdminAll();

    // 根据ID删除管理员
    @Delete("DELETE FROM Admin WHERE admin_id = #{admin_id}")
    int deleteAdminById(int admin_id);

    // 添加管理员
    @Insert("INSERT INTO Admin (username, password, email, create_date,sex,operator,avatar) VALUES (#{username}, #{password}, #{email}, NOW(),#{sex},#{operator},#{avatar})")
    int addAdmin(Admin admin);

    // 根据邮箱查找管理员
    @Select("SELECT * FROM Admin WHERE email = #{email}")
    Admin findAdminByEmail(String email);

    // 根据邮箱查找管理员
    @Select("SELECT * FROM Admin WHERE email = #{email}")
    List<Admin> findAdminByEm(String email);

    // 根据用户名查找管理员
    @Select("SELECT * FROM Admin WHERE username = #{username}")
    List<Admin> findAdminByName(String username);
}


